Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mypyc] Inline tagged integer arithmetic and bitwise operations #17265

Merged
merged 8 commits into from
Jun 6, 2024

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented May 19, 2024

Inline the fast path of various tagged integer operations by using C inline functions.
Most of these operations are very quick, so getting rid of the overhead of a C call
improves performance significantly. This also enables the C compiler to optimize
things more, if there are constant operands, for example.

This speeds up an older version of the richards benchmark, which didn't use native
integers, by 10% (on CPython 3.12). Even bigger improvements are possible in
some microbenchmarks.

We didn't do this in the past because of worries about compilation time. However,
I couldn't measure an impact to self-compilation speed, and the binary size is
only increased by about 0.1%.

Work on mypyc/mypyc#757.

Copy link
Member

@ilevkivskyi ilevkivskyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

@JukkaL JukkaL merged commit 09c48a4 into master Jun 6, 2024
13 checks passed
@JukkaL JukkaL deleted the mypyc-int-inline branch June 6, 2024 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants